package com.erp.programmer.controller;


import com.erp.programmer.bean.CodeMsg;
import com.erp.programmer.dto.PurchaseOrderDetailDto;
import com.erp.programmer.dto.PurchaseOrderDto;
import com.erp.programmer.dto.ResponseDto;
import com.erp.programmer.service.IPurchaseOrderDetailService;
import com.erp.programmer.utils.CommonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 陈鑫
 * @since 2021-05-24
 */
@RestController
@RequestMapping("/purchase_order_detail")
@CrossOrigin
public class PurchaseOrderDetailController {
    @Autowired
    IPurchaseOrderDetailService iPurchaseOrderDetailService;
    @PostMapping("/get_data")
    public ResponseDto<List<PurchaseOrderDetailDto>> getOrderDetail(@RequestBody PurchaseOrderDto purchaseOrderDto) {
        if (purchaseOrderDto==null || CommonUtil.isEmpty(purchaseOrderDto.getId())) {
            return ResponseDto.errorByMsg(CodeMsg.DATA_ERROR);
        }
        return iPurchaseOrderDetailService.getOrderDetail(purchaseOrderDto.getId());
    }
}

